package telegram

import (
	"fmt"
	"strings"

	tgApi "github.com/go-telegram-bot-api/telegram-bot-api"
	"github.com/nchursin/formtgbot/telegram/routes"
)

func Routes(update *tgApi.Update) {
	if nil != update.CallbackQuery {
		callbackQueryRouting(update.CallbackQuery)
	}
}

func callbackQueryRouting(query *tgApi.CallbackQuery) {
	if strings.HasPrefix(query.Data, "confirm:") {
		vacancy := routes.Confirm(query.Data)
		GetBot().SendTextMessage(fmt.Sprintf("publishing: %s", string(vacancy.ToJson())))
		GetBot().PostToChannel(vacancy)
	}
}
